package com.laborder.sysyy.controller.classes;
import com.laborder.sysyy.service.classes.ClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.HashMap;
import java.util.Map;


@Controller
@RequestMapping(value = "classes")
public class ClassController {
	@Autowired
	private ClassService classService;

	@GetMapping("toClasses")
	public String toClasses(Model model){
		return "/classes/classesList";
	}
	@RequestMapping("/findClassWithPage")
	public Map<String,Object> findClassWithPage(int page,int rows,String caName){
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("page", (page-1)*rows);
		map.put("rows", rows);
		map.put("caName", caName);
		Map<String,Object> resultmap = new HashMap<String, Object>();
		resultmap.put("total", classService.getClassCount(map));
		resultmap.put("rows", classService.findClassWithPage(map));
		return resultmap;
	}
	
	
	
}